
<!DOCTYPE html>
<html lang="zh-CN" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>会员登陆</title>
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="/css/login_view.css" >
    <!--<script src='/js/irm1.1.js' language="JavaScript"></script>
    <script src='/js/jquery.min.js' language='javascript'></script>
    <script src='/js/vue.min.js' language='javascript'></script>-->
    <script src="/js/wxLogin.js"></script>
    <script src="/js/global.js"></script>
</head>
<body>
<div class="header">
    <div class="main">
        <a href="//www.xuezizhai.com/"><div class="logo"></div></a>
    </div>
</div>
<div class="login_main" id="vue_body">
    <div class="main">
        <div class="login-box">

                    <div v-else id="logintype">
                        <div class="nav_tab">
                            <div class="title">账号登录</div>
                            <i class="longinicon saoma" @click="set(true)"></i>
                            <div class="login-tip" @click="set(true)">
                                <div class="poptip">
                                    <div class="poptip-arrow"><em></em><span></span></div>
                                    <div class="poptip-content">扫码登录</div>
                                </div>
                            </div>
                        </div>
                        <div class="account" v-show="logintype=='account'">
                            <div class="loginuser">
                                <span class="userid"></span>
                                <input type="text" v-model="userpost.userid" placeholder="手机/邮箱/账号">
                            </div>
                            <div id="useridmsg" class="msg"></div>
                            <div class="loginuser">
                                <span class="pwd"></span>
                                <input type="password"  v-model="userpost.pwd" placeholder="请输入密码">
                            </div>
                            <div id="pwdmsg" class="msg"></div>
                            <div class="submit" @click="account()">登录</div>
                        </div>
                        <div class="h0"></div>
                        <div class="loginmore" v-show="logintype=='account'||logintype=='mobile'">
                            <div style="float:left;">
                                <a href="registration.jsp">注册</a>
                            </div>

                            <div class="getpwd" ><a href="?s=40&cm=getpwd" target="_top">忘记密码</a></div>
                        </div>
                        <div class="h0"></div>
                        <div class="otherlogin">
                            <div class="otherlogin-text">其他方式登录：</div>
                           <!-- <div class="otherlogin-login">
                                <a href="javascript:void(0)" @click="selType('mobile')"  class="mobilelogin"></a>
                                <a href="javascript:void(0)" @click="selType('account')" class="account"></a>
                                <a v-for="item in typelist" href="javascript:void(0)" v-bind:class="item.logintype" @click="selType(item.logintype)"></a>
                            </div>-->
                        </div>
                        <div class="h0"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var D= new Vue({
        el: '#vue_body',
        data:{
            url:'?s=40&view=login',
            forward:'http://www.xuezizhai.com/',//回跳地址
            qrcodeUrl:'',//二维码地址
            appqrcode:false,//i学习课堂扫码
            logintype:'account',//登陆方式
            typelist:[],//登陆方式
            userpost:{userid:'',pwd:'',action:1},//账号登陆信息
            codenum:'',//验证码
            codenummsg:'',//验证码错误信息
            fromuser:'',//我的
            touser:'',
            isws:false,
            qrcodeopen:false,//扫码是否成功
            t:0,
        },
        methods:{
            init:function(){
                var self=this;
                Plug.member.getLoginType(function(ret){
                    console.log(ret)
                    if(ret.status)
                    {
                        self.typelist=ret.data;
                    }
                    var logintype='';
                    if(logintype)
                    {
                        self.selType(logintype);
                    }
                    else
                    {
                        self.webS();
                    }
                })
            },
            set:function(appqrcode){
                clearInterval(this.t);
                this.appqrcode=appqrcode;
            },
            webS:function(){
                this.isws=true;
                var self=this;
                Plug.open('websocketlogin',function(){
                    self.ws=Plug.websocketlogin.open({
                        init:function(){
                            console.log('init');
                            self.ws.send('type=getuser');
                        },
                        back:function(ret){
                            switch(ret.eventType)
                            {
                                //获取用户id
                                case 'getuser':
                                    self.fromuser=ret.fromuser;
                                    self.getQrcode();
                                    break;
                                //用户扫码成功
                                case 'qrcodeopen':
                                    self.touser=ret.fromuser;
                                    self.qrcodeopen=true;
                                    break;
                                //授权成功
                                case 'empower':
                                    self.login();
                                    break;
                                //取消授权
                                case 'close':
                                    self.qrcodeopen=false;
                                    self.getQrcode();
                                    irm.toast({msg:'取消授权'})
                                    break;
                            }
                        },
                        error:function(){
                            self.getQrcode();
                        }
                    });
                });
            },
            //账号登陆
            account:function(){
                var self=this;
                Plug.member.getData({view:'login',cm:'app'},function(ret){
                    //修改成功
                    if(ret.status==3)
                    {
                        self.back(ret.data);
                    }
                    else
                    {
                        $('#pwdmsg').html(ret.data);
                    }
                },this.userpost);
            },
      /*      //手机登陆
            mobile:function(){
                var self=this;
                var data={codenum:this.codenum};
                var para={view:'mobile',cm:'login',action:3};//验证手机号码
                Plug.member.getData(para,function(ret){
                    //登陆成功
                    if(ret.status==3)
                    {
                        self.back(ret.data);
                    }
                    //验证码输入错误
                    else if(ret.status==6)
                    {
                        self.codenummsg='验证码输入错误';
                    }
                    //验证码输入错误
                    else if(ret.status==5)
                    {
                        self.codenummsg='验证码输入错误,重新登陆';
                    }
                    else
                    {
                        self.codenummsg=ret.data;
                    }
                },data);
            },*/
            account:function(){
                var self=this;
                Plug.member.getData({view:'login',cm:'app'},function(ret){
                    //修改成功
                    if(ret.status==3)
                    {
                        self.back(ret.data);
                    }
                    else
                    {
                        $('#pwdmsg').html(ret.data);
                    }
                },this.userpost);
            },
            //登陆成功回调
            back:function(item){
                location.href=this.forward;
            }
        },
        watch:{
            logintype:function(){
                this.$nextTick(function(){
                    if(this.logintype=='mobile')
                    {
                        Plug.member.mobile.code('mobile','codebtn');
                    }
                });
            },
            appqrcode:function(){
                this.$nextTick(function(){
                    if(this.appqrcode)
                    {
                        if(this.isws)
                        {
                            this.getQrcode();
                        }
                        else
                        {
                            this.webS();
                        }
                    }
                });
            }
        },
        mounted:function(){
            var self=this;
            Plug.open('member',function(){
                self.init();
            })
        }
    })
</script>
</body>
</html>